package com.holyant.goods.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.holyant.goods.enums.SpecsQtyEnum;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @Author: Ssw
 * @CreateTime: 2022-11-24  10:41
 * @Description: 销售价管理页面导出
 */

@Data
public class GdsSkuQuoteSalesManagePageExportDto {



    /** 编码 */
    @Excel(name = "销售价调价单号")
    private String code;

    /** 审核状态  10 待审核 50 审核中  100 已审核 */
    @Excel(name = "状态")
    private String auditStatusStr;
    private Integer auditStatus;


    @Excel(name = "渠道类型")
    private String salesChannelStr;
    private Integer salesChannel;


    @Excel(name = "店铺名称")
    private String shopName;
    /** 客户名称 */
    @Excel(name = "客户名称")
    private String customerName;

    @Excel(name = "平台")
    private String platformName;
    private String platform;

    /** 报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税 */
    @Excel(name = "报价方式")
    private String  quoteMethodStr;
    private Integer quoteMethod;


    /** 币种 */
    @Excel(name = "币种")
    private String curTypeStr;
    private Integer curType;

    /** sku编码 */
    @Excel(name = "sku编码")
    private String skuCode;


    /** 商品名称 */
    @Excel(name = "商品名称")

    private String goodsName;

    /** 商品编码 */
   // @Excel(name = "商品编码")
    private String goodsCode;

    /** 商品条码 */
    @Excel(name = "商品条码")
    private String goodsBarcode;



    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate expireDate;
    @Excel(name = "效期", width = 30)
    private String expireDateStr;

    @Excel(name = "1 pcs")
    private String pcs1;

    @Excel(name = "2 pcs")
    private String pcs2;

    @Excel(name = "3 pcs")
    private String pcs3;

    @Excel(name = "4 pcs")
    private String pcs4;

    @Excel(name = "5 pcs")
    private String pcs5;

    @Excel(name = "6 pcs")
    private String pcs6;


    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate effectiveTimeStart;
    @Excel(name = "计划生效时间", width = 30)
    private String effectiveTimeStartStr;

    /** 审核时间 */
    @Excel(name = "实际生效时间", width = 30)
    private String auditTimeStr;
    private LocalDateTime auditTime;

    /** 失效日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate effectiveTimeEnd;
    @Excel(name = "失效时间", width = 30)
    private String effectiveTimeEndStr;

    @Excel(name = "申请人", width = 30)
    private String createBy;


    private LocalDateTime createTime;

    @Excel(name = "创建时间", width = 30)
    private String createTimeStr;

    /** 描述 */
    @Excel(name = "申请原因")
    private String remark;


    protected String priceObj;




    public void initPrice() {
        if (Objects.nonNull(priceObj)) {
            JSONObject jsonObject = JSON.parseObject(priceObj);
            for (int i = 1; i <= 6; i++) {
                SpecsQtyEnum specsQtyEnum = SpecsQtyEnum.parseByName(String.valueOf(i));
                if (i == 1 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs1(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 2 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs2(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 3 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs3(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 4 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs4(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 5 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs5(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 6 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs6(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
            }
        }
    }

}
